package com.zyk.leetcode;

/**
 * @author zhangsan
 * @date 2021/4/10 12:51
 */
public class C263 {

    // https://leetcode-cn.com/problems/ugly-number/
    public static boolean isUgly(int n) {
        if(n <= 0) {
            return false;
        }
        while (n % 2 == 0) {
            n /= 2;
        }
        while (n % 3 == 0) {
            n /= 3;
        }
        while (n % 5 == 0) {
            n /= 5;
        }
        return n == 1;
    }


    // for test
    public static void main(String[] args) {
        int n = 8;
        System.out.println(isUgly(n));
    }


}
